home *** CD-ROM | disk | FTP | other *** search
/ APDL Eductation Resources / APDL Eductation Resources.iso / programs / electronic / rlab / TestMatrix / triw_r < prev    next >
Encoding:
Text File  |  1994-12-20  |  2.1 KB  |  60 lines

  1. //-------------------------------------------------------------------//
  2.  
  3. // Synopsis:    Upper triangular matrix discussed by Wilkinson and others.
  4.  
  5. // Syntax:    T = triw ( N , ALPHA , K )
  6.  
  7. // Description:
  8.  
  9. //    T is the upper triangular matrix with ones on the diagonal and
  10. //    ALPHAs on the first K >= 0 superdiagonals. N may be a
  11. //    2-vector, in which case the matrix is N(1)-by-N(2) and upper
  12. //    trapezoidal. 
  13.  
  14. //      Defaults: ALPHA = -1,
  15. //                K = N - 1     (full upper triangle).
  16. //      TRIW(N) is a matrix discussed by Kahan, Golub and Wilkinson.
  17. //
  18. //      Ostrowski (1954) shows that
  19. //         COND(TRIW(N,2)) = COT(PI/(4*N))^2,
  20. //      and for large ABS(ALPHA),
  21. //         COND(TRIW(N,ALPHA)) is approximately ABS(ALPHA)^N*SIN(PI/(4*N-2)).
  22.  
  23. //      Adding -2^(2-N) to the (N,1) element makes TRIW(N) singular,
  24. //    as does adding -2^(1-N) to all elements in the first column. 
  25.  
  26. //      References:
  27. //      G.H. Golub and J.H. Wilkinson, Ill-conditioned eigensystems and the
  28. //          computation of the Jordan canonical form, SIAM Review,
  29. //          18(4), 1976, pp. 578-619.
  30. //      W. Kahan, Numerical linear algebra, Canadian Math. Bulletin,
  31. //          9 (1966), pp. 757-801.
  32. //      A.M. Ostrowski, On the spectrum of a one-parametric family of
  33. //          matrices, J. Reine Angew. Math., 193 (3/4), 1954, pp. 143-160.
  34. //      J.H. Wilkinson, Singular-value decomposition---basic aspects,
  35. //          in D.A.H. Jacobs, ed., Numerical Software---Needs and Availability,
  36. //          Academic Press, London, 1978, pp. 109-135.
  37.  
  38. //    This file is a translation of triw.m from version 2.0 of
  39. //    "The Test Matrix Toolbox for Matlab", described in Numerical
  40. //    Analysis Report No. 237, December 1993, by N. J. Higham.
  41.  
  42. //-------------------------------------------------------------------//
  43.  
  44. triw = function ( n , alpha , k )
  45. {
  46.   local ( n , alpha , k )
  47.  
  48.   m = n[1];        // Parameter n specifies dimension: m-by-n.
  49.   n = n[max(size(n))];
  50.  
  51.   if (!exist (k)) { k = n-1; }
  52.   if (!exist (alpha)) { alpha = -1; }
  53.  
  54.   if (max(size(alpha)) != 1) {
  55.     error("Second argument must be a scalar.");
  56.   }
  57.  
  58.   return tril( eye(m,n) + alpha*triu(ones(m,n), 1), k);
  59. };
  60.